//
//  VenueVipTableHeadView.m
//  fitnessmanage
//
//  Created by 众拳科技 on 2017/10/26.
//  Copyright © 2017年 zongquankeji. All rights reserved.
//

#import "VenueVipTableHeadView.h"

@implementation VenueVipTableHeadView

-(id)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        self.backgroundColor = BackGroundColor;
        
        /**
         搜索
         */
        SearchView *searchView = [[SearchView alloc] init];
        searchView.placeholder = @"请输入会员名、会员卡号、手机";
        searchView.backgroundColor = CSWhiteColor;
        [self addSubview:searchView];
        self.searchView = searchView;
        
        /**
         生日提醒
         */
        UIButton *sortBtn = [[UIButton alloc] init];
        sortBtn.backgroundColor = CSWhiteColor;
        [sortBtn setTitle:@"生日提醒"];
        sortBtn.titleLabel.font = [UIFont systemFontOfSize:15.0];
        [sortBtn setSelectedTitleColor:CSColorFromRGB(0x0a0a0a)];
        [sortBtn setTitleColor:CSColorFromRGB(0x666666)];
        sortBtn.titleLabel.font = MidBigFont;
        [sortBtn setImage:@"icon_cardrenewal"];
//        sortBtn.selected = YES;
        [self addSubview:sortBtn];
        self.sortBtn = sortBtn;
        
        /**
         续卡提醒
         */
        UIButton *sortRegBtn = [[UIButton alloc] init];
        sortRegBtn.backgroundColor = CSWhiteColor;
        sortRegBtn.titleLabel.font = [UIFont systemFontOfSize:15.0];
        [sortRegBtn setTitle:@"续卡提醒"];
        [sortRegBtn setImage:@"icon_cardrenewal"];
        [sortRegBtn setSelectedTitleColor:CSColorFromRGB(0x0a0a0a)];
        [sortRegBtn setTitleColor:CSColorFromRGB(0x666666)];
        sortRegBtn.titleLabel.font = MidBigFont;
        [self addSubview:sortRegBtn];
        self.sortRegBtn = sortRegBtn;
        
        UIView *verLineView = [[UIView alloc] init];
        verLineView.backgroundColor = CSColorFromRGB(0x0a0a0a);
        [self addSubview:verLineView];
        self.verLineView = verLineView;
        
        /**
         刷选
         */
        UIButton *fitBtn = [[UIButton alloc] init];
        fitBtn.backgroundColor = CSWhiteColor;
        [fitBtn setTitle:@"筛选"];
        [fitBtn setTitleColor:CSColorFromRGB(0x666666)];
        [fitBtn setSelectedTitleColor:CSColorFromRGB(0x0a0a0a)];
        [fitBtn setImage:@"icon_select"];
        fitBtn.titleLabel.font = [UIFont systemFontOfSize:15.0];
        [self addSubview:fitBtn];
        self.fitBtn = fitBtn;
        
        
        UIView *horLineView = [[UIView alloc] init];
        horLineView.backgroundColor = LineBackGroundColor;
        [self addSubview:horLineView];
        self.horLineView = horLineView;
        
        
        UIView *noticeView = [[UIView alloc] init];
        noticeView.backgroundColor = CSColorFromRGB(0xfaf6e8);
        [self addSubview:noticeView];
        self.noticeView = noticeView;
//        [headImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
//            make.centerY.mas_equalTo(tableHeadView);
//            make.left.mas_equalTo(tableHeadView).offset(13);
//        }];
        UILabel *vipCountLabel = [[UILabel alloc] init];
        vipCountLabel.text = @"会员人数：";
        vipCountLabel.font = [UIFont systemFontOfSize:13.0];
        vipCountLabel.textColor = CSColorFromRGB(0x999999);
        [self addSubview:vipCountLabel];
        self.vipCountLabel = vipCountLabel;
        
        UILabel *vipCountLabel1 = [[UILabel alloc] init];
        vipCountLabel1.text = @"0人";
        vipCountLabel1.font = MidFont;
        vipCountLabel1.textColor = CSColorFromRGB(0x333333);
        [self addSubview:vipCountLabel1];
        self.vipCountLabel1 = vipCountLabel1;
        
//        [titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
//            make.centerY.mas_equalTo(tableHeadView);
//            make.left.mas_equalTo(headImageView.mas_right).offset(10);
//        }];
        
        [self setConstraints];
    }
    
    return self;
}

-(void)setConstraints{
    
    
    /**
     搜索
     */
    [self.searchView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self).offset(10);
        
        make.left.mas_equalTo(self).offset(20);
        
        make.right.mas_equalTo(self).offset(-20);
        
        make.height.mas_equalTo(40);
    }];
    
    
    /**
     字母排序
     */
    [self.sortBtn mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.top.mas_equalTo(self.searchView.mas_bottom).offset(10);

        make.left.mas_equalTo(self);

        make.height.mas_equalTo(50);

        //make.bottom.mas_equalTo(self);
    }];

    /**
     最新注册
     */
    [self.sortRegBtn mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.top.width.height.mas_equalTo(self.sortBtn);

        make.left.mas_equalTo(self.sortBtn.mas_right);
    }];

    /**
     刷选
     */
    [self.fitBtn mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.top.width.height.mas_equalTo(self.sortBtn);

        make.left.mas_equalTo(self.sortRegBtn.mas_right);

        make.right.mas_equalTo(self);
    }];

    [self.verLineView mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.centerX.mas_equalTo(self.sortBtn);

        make.height.mas_equalTo(3);

        make.width.mas_equalTo(self.sortBtn).multipliedBy(2.0 / 3);
        
        make.bottom.mas_equalTo(self.sortBtn.mas_bottom);
    }];
    
    [self.horLineView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.sortBtn.mas_bottom);
        
        make.left.width.mas_equalTo(self);
        
        make.height.mas_equalTo(1);
    }];
    
    [self.noticeView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.horLineView.mas_bottom);
        
        make.left.width.mas_equalTo(self);
        
        make.height.mas_equalTo(40);
        
        make.bottom.mas_equalTo(self);
    }];
    
    [self.vipCountLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.right.mas_equalTo(self.mas_centerX).offset(-5);
        make.centerY.mas_equalTo(self.noticeView);
    }];
    
    [self.vipCountLabel1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self.mas_centerX).offset(5);
        make.centerY.mas_equalTo(self.noticeView);
    }];
}

-(void)layoutSubviews{

    /**
     生日提醒
     */
    [self.fitBtn imageOnTheTitleLeftWithSpace:5];
    
    /**
     续卡提醒
     */
    [self.sortRegBtn imageOnTheTitleLeftWithSpace:5];
    
    
}
@end
